<template>
  <div class="settings-page">
    <div class="settings-container">
      <SettingsHeader />
      
      <div class="settings-content-wrapper">
        <div class="settings-content">
          <BookSwitcher />
          <AdvancedSettings />
          <LanguageSwitcher />
          
          <!-- 未来可以在这里添加更多设置选项 -->
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import SettingsHeader from './SettingsHeader.vue';
import BookSwitcher from './BookSwitcher.vue';
import AdvancedSettings from './AdvancedSettings.vue';
import LanguageSwitcher from './LanguageSwitcher.vue';
import { useI18n } from 'vue-i18n';
import { useUserStore } from '@/stores/user';
import { useSettingsStore } from '@/stores/settings';
import { onMounted } from 'vue';

const { t } = useI18n();
const userStore = useUserStore();
const settingsStore = useSettingsStore();

onMounted(() => {
  // 确保用户信息已加载
  if (userStore.isAuthenticated && !userStore.user) {
    userStore.loadUser();
  }
  
  // 初始化设置
  if (!settingsStore.initialized) {
    settingsStore.fetchSettings();
  }
  
  // 确保页面可滚动
  document.body.style.overflow = 'auto';
});
</script>

<style scoped>
.settings-page {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000;
}

.settings-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-content-wrapper {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

.settings-content {
  width: 100%;
  max-width: 800px;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 2rem;
  margin-bottom: 2rem;
}

/* 确保在移动设备上也能正常滚动 */
@media (max-width: 768px) {
  .settings-content-wrapper {
    padding: 1rem;
  }
  
  .settings-content {
    padding: 1.5rem;
  }
}

/* 确保在较小的屏幕上内容不会被截断 */
@media (max-height: 700px) {
  .settings-content-wrapper {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .settings-content {
    padding: 1.5rem;
  }
}
</style> 